import { combineReducers } from 'redux';

// 拆分
const list = (list = {
  tab: 'all',
  page: 1,
  typeid: 0,
  data: []
}, action) => {
  switch (action.type) {
    case 'LIST_DATA':
      let data = action.data;
      return {
        ...list,
        data: data.data,
        page: data.current_page,
      }
  }
  return list;
}

const article = (article = {
  detail: {},
  message: []
}, action) => {
  switch (action.type) {
    case 'ARTICLE_ADD':
      const { message } = article;
      message.push('b');
      return {
        ...article,
        message
      }
  }
  return article;
}

// const reducer = (state = {}, action) => {
//   return {
//     list: list(state.list, action),
//     article: article(state.article, action)
//   }
// }

export default combineReducers({
  list,
  article
});